package day1802;

public class day180202 extends Thread{
    static int a =100;

    @Override
    public void run() {
        while (true){
            synchronized (day180202.class){//锁住静态变量，需要调用类名.class
                if(a>0){
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName()+" "+a--);
                }else{
                    break;
                }
            }

        }
    }
}

